package com.ruoyi.college.controller;

import java.util.List;

import com.ruoyi.college.domain.ExperimentScoreStandard;
import com.ruoyi.college.service.IExperimentScoreStandardService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.college.domain.ExperimentClassProject;
import com.ruoyi.college.service.IExperimentClassProjectService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 班级实验内容安排Controller
 * 
 * @author ruoyi
 * @date 2025-08-30
 */
@Controller
@RequestMapping("/college/classExperimentProject")
public class ExperimentClassProjectController extends BaseController
{
    private String prefix = "college/classExperimentProject";

    @Autowired
    private IExperimentClassProjectService experimentClassProjectService;

    @Autowired
    private IExperimentScoreStandardService  experimentScoreStandardService;

    @RequiresPermissions("college:classExperimentProject:view")
    @GetMapping()
    public String classExperimentProject()
    {
        return prefix + "/classExperimentProject";
    }

    /**
     * 查询班级实验内容安排列表
     */
    @RequiresPermissions("college:classExperimentProject:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ExperimentClassProject experimentClassProject)
    {
        startPage();
        List<ExperimentClassProject> list = experimentClassProjectService.selectExperimentClassProjectList(experimentClassProject);
        return getDataTable(list);
    }



    /**
     * 导出班级实验内容安排列表
     */
    @RequiresPermissions("college:classExperimentProject:export")
    @Log(title = "班级实验内容安排", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ExperimentClassProject experimentClassProject)
    {
        List<ExperimentClassProject> list = experimentClassProjectService.selectExperimentClassProjectList(experimentClassProject);
        ExcelUtil<ExperimentClassProject> util = new ExcelUtil<ExperimentClassProject>(ExperimentClassProject.class);
        return util.exportExcel(list, "班级实验内容安排数据");
    }

    /**
     * 新增班级实验内容安排
     */
    @RequiresPermissions("college:classExperimentProject:add")
    @GetMapping("/add")
    public String add(ModelMap mmap)
    {
        List<ExperimentScoreStandard> experimentScoreStandards = experimentScoreStandardService.selectExperimentScoreStandardList(new ExperimentScoreStandard());
        mmap.put("experimentStandards", experimentScoreStandards);
        return prefix + "/add";
    }

    /**
     * 新增保存班级实验内容安排
     */
    @RequiresPermissions("college:classExperimentProject:add")
    @Log(title = "班级实验内容安排", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ExperimentClassProject experimentClassProject)
    {
        return toAjax(experimentClassProjectService.insertExperimentClassProject(experimentClassProject));
    }

    /**
     * 修改班级实验内容安排
     */
    @RequiresPermissions("college:classExperimentProject:edit")
    @GetMapping("/edit/{classProjectId}")
    public String edit(@PathVariable("classProjectId") Long classProjectId, ModelMap mmap)
    {
        ExperimentClassProject experimentClassProject = experimentClassProjectService.selectExperimentClassProjectByClassProjectId(classProjectId);
        mmap.put("experimentClassProject", experimentClassProject);
        return prefix + "/edit";
    }

    /**
     * 修改保存班级实验内容安排
     */
    @RequiresPermissions("college:classExperimentProject:edit")
    @Log(title = "班级实验内容安排", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ExperimentClassProject experimentClassProject)
    {
        return toAjax(experimentClassProjectService.updateExperimentClassProject(experimentClassProject));
    }

    /**
     * 删除班级实验内容安排
     */
    @RequiresPermissions("college:classExperimentProject:remove")
    @Log(title = "班级实验内容安排", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(experimentClassProjectService.deleteExperimentClassProjectByClassProjectIds(ids));
    }
}
